home *** CD-ROM | disk | FTP | other *** search
/ Macintosh Programmer's Tool Box Assistant / Macintosh Programmer's Tool Box Assistant.iso / Goodies / Toolbox Asst. Tools for MPW / MPTA_MPWAccess next >
Encoding:
Text File  |  1995-01-12  |  2.6 KB  |  73 lines  |  [TEXT/MPS ]

  1. # Macintosh Programmer’s Toolbox Assistant
  2. # Copyright © 1986-1995 Apple Computer, Inc. All rights reserved.
  3. #
  4. # -- brain surgery provided by the MPW doctors, 1/12/95
  5. #
  6. # ------------------------------- #
  7. # MPTA_MPWAccess
  8. # ------------------------------- #
  9. #
  10. # Put this file in the MPW Scripts folder.
  11. #
  12. # This MPW script allows you to access the Macintosh Programmer’s Toolbox Assistant
  13. # Apple Event commands from the MPW shell. It depends upon the {MPTA_Location} and
  14. # {MPTA_AppName} variables being defined and the MPTA menu being added by the
  15. # UserStartup•MPTA script. It also depends upon the existence of the SendAE tool in
  16. # the MPW Tools folder.
  17. #
  18. # {1} = name of the Macintosh Programmer’s Toolbox Assistant command to execute
  19. #
  20.  
  21. set thisMPTA_AECommand "{1}"
  22.  
  23. unset thisSelectedTerm                                        # initialize
  24.  
  25. If "`Catenate "{Active}.§"`" == ""
  26.     set exit 0
  27.     find \[¬{wordset}]\Δ:Δ/[¬{wordset}]/  "{Active}"        # select the current word
  28.     if "{status}" ≠ 0
  29.         if `position -l "{Active}"` == 1                    # first word in file?
  30.             find •:/[{wordset}]+/ "{Active}"                # yes, select it
  31.         else                                                # else must be word at end of file
  32.             find \[¬{wordset}]\Δ:∞  "{Active}"                # select the current word
  33.         end
  34.     end
  35. end
  36. set thisSelectedTerm "`Catenate "{Active}.§"`"                # remember the current selection
  37.  
  38. # The following code checks the MPW Shell version number to see
  39. # if we can use the -background option when launching an
  40. # application. (We can for versions 3.4 and later.). We want to
  41. # launch QuickView into the background when retrieving template
  42. # information so that the MPW Shell will remain in the foreground.
  43. #
  44. (evaluate "`version`" =~ /≈([0-9]+)®1.([0-9]+)®2≈/) ∑dev:null
  45. if "{®1}{®2}" >= 34 
  46.     set MPTA_Options "-background"
  47. else
  48.     set MPTA_Options ""
  49. end
  50.  
  51. If "{thisMPTA_AECommand}" == "Lookup"
  52.     set exit 0
  53.    (SendAE -e "DanRREF " -t "{MPTA_AppName}" -----TEXT "{thisSelectedTerm}") ≥ "{TempFolder}"errorInfo
  54.     if "`catenate "{TempFolder}"errorInfo`" != ""
  55.         "{MPTA_Location}"
  56.            SendAE -e "DanRREF " -t "{MPTA_AppName}" -----TEXT "{thisSelectedTerm}"|| Beep
  57.     end ∑∑"{Worksheet}"
  58. else if "{thisMPTA_AECommand}" == "GetTemplate"
  59.     set exit 0
  60.        set tmpl "`(SendAE -e "DanRTMPL" -t "{MPTA_AppName}" -dot -----TEXT "{thisSelectedTerm}") ≥ "{TempFolder}"errorInfo`"
  61.     if "`catenate "{TempFolder}"errorInfo`" != ""
  62.         "{MPTA_Location}" {MPTA_Options}
  63.            Set tmpl "`SendAE -e "DanRTMPL" -t "{MPTA_AppName}" -dot -----TEXT "{thisSelectedTerm}"  || Beep`"
  64.     end ∑∑"{Worksheet}"
  65.     if "{tmpl}" != ""
  66.         echo "{tmpl}" >"{Active}".§
  67.     End
  68. else
  69.     Alert "Macintosh Programmer’s Toolbox Assistant error: ∂n∂n   “unrecognized command”"
  70. end
  71.  
  72. delete -i -y "{TempFolder}"errorInfo ∑dev:null
  73.